package Towers;

import java.awt.Graphics2D;
import java.awt.image.BufferedImage;

import Utils.Utilidades;

public class FX_Buff {

	public BufferedImage tileSet;
	int x, y;
	int sizeX, sizeY;
	int frame, timer;
	int entreFrame = 500;
	boolean play;
	int numeroFrames;

	public FX_Buff(int X, int Y, int SizeX, int SizeY, int delayTiro, String fileName) {
		x= X;
		y =Y;
		sizeX = SizeX;
		sizeY = SizeY;
		tileSet = Utilidades.LoadImage(fileName);
		numeroFrames = tileSet.getWidth()/sizeX;
		play = false;
		entreFrame = delayTiro / (numeroFrames+2);
		
	}
	
	public void draw(Graphics2D dbg){
		if(play){
//			System.out.println("Desenhando "+frame);
			dbg.drawImage(tileSet, x, y, x+sizeX, y+sizeY, frame*sizeX, 0, (frame*sizeX)+sizeX,  sizeY, null);
		}
		
	}
	
	public void update(long diffTime){
		
		timer+=diffTime;
		frame = (timer/entreFrame)%numeroFrames;
		
	}
	
	public void startAnimacao(){
		play = true;
	}
	
	public void setPosition(int X, int Y){
		play = true;
		x= X - sizeX/2;
		y =Y - sizeY/2;
	}
}
